package com.teach.servlet.web1;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teach.entity.News;
import com.teach.service.NewsService;
import com.teach.service.impl.NewsServiceImpl;

@WebServlet("/web1/news-list.s")
public class NewsListServlet extends HttpServlet {

	private NewsService service = new NewsServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int current = 1;
		int rowMax = 10;
		
		try {
			String c = request.getParameter("current");
			current  = Integer.valueOf(c);
		}catch (Exception e) {
		}
		
		try {
			String c = request.getParameter("rowMax");
			rowMax  = Integer.valueOf(c);
		}catch (Exception e) {
		}
		
		Object p = service.page(current, rowMax);
		
		request.setAttribute("p", p);
		request.getRequestDispatcher("/web1/news-list.jsp").forward(request, response);
		
	}
}
